package cn.fws.meap.user.web;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.fws.meap.user.entity.Msg;
import cn.fws.meap.user.service.IMsgService;
import cn.fws.framework.web.contoller.BaseController;
import cn.fws.framework.web.page.PagingResult;
import cn.fws.framework.web.contoller.JsonResponse;

/**
 * 消息 信息操作处理
 * 
 * @author chenkh
 * @date 2019-03-07
 */
@RestController
@RequestMapping("/meap/msg")
@Api(tags = "消息 信息操作处理")
public class MsgController extends BaseController{

	@Autowired
	private IMsgService msgService;
	
	/**
	 * 查询消息列表
	 */
	//@RequiresPermissions("meap:msg:list")
	@ApiOperation(value = "查询消息列表")
	@PostMapping("/list")
	public PagingResult<Msg> list(Msg msg){
		startPage();
        List<Msg> list = msgService.selectList(msg);
		return getPagingResult(list);
	}
	
	/**
	 * 新增保存消息
	 */
	//@RequiresPermissions("meap:msg:add")
	@ApiOperation(value = "新增保存消息")
	@ApiImplicitParam(name = "msg", value = "新增保存消息",dataType = "Msg")
	@PostMapping("/add")
	public JsonResponse addSave(Msg msg)	{		
		return toAjax(msgService.insert(msg));
	}

	/**
	 * 修改保存消息
	 */
	//@RequiresPermissions("meap:msg:edit")
	@ApiOperation(value = "修改保存消息")
	@ApiImplicitParam(name = "msg", value = "修改保存消息",dataType = "Msg")
	@PutMapping("/edit")
	public JsonResponse editSave(Msg msg)	{		
		return toAjax(msgService.update(msg));
	}
	
	/**
	 * 删除消息
	 */
	//@RequiresPermissions("meap:msg:remove")
	@ApiOperation(value = "删除消息")
	@ApiImplicitParam(name = "ids", value = "根据id删除消息",dataType = "String")
	@DeleteMapping( "/remove")
	public JsonResponse remove(String ids)	{		
		return toAjax(msgService.deleteByIds(ids));
	}
	
}
